package com.ys.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ys.web.dao.CommonDao;
import com.ys.web.entity.KeyWordMaping;
import com.ys.web.service.KeyWordMapingService;

/**
 * 推广关键词对应多个搜索关键词-Service-实现类
 * @author wdj
 *
 */
@Service("keyWordMapingService")
@Transactional
public class KeyWordMapingServiceImpl implements KeyWordMapingService {
	@Autowired
	private CommonDao commonDao;
	
	@Override
	public void delete(KeyWordMaping entity) {
		// TODO Auto-generated method stub
		commonDao.delete(entity);
	}

	@Override
	public Integer save(KeyWordMaping entity) {
		// TODO Auto-generated method stub
		return (Integer) commonDao.save(entity);
	}

	@Override
	public void saveOrUpdate(KeyWordMaping entity) {
		// TODO Auto-generated method stub
		commonDao.saveOrUpdate(entity);
	}

 	/**
 	 * 批量新增
 	 * @param entitys
 	 */
	@Override
	public void batchSave(List<KeyWordMaping> entitys) {
		// TODO Auto-generated method stub
		commonDao.batchSave(entitys);
	}

 	/**
 	 * 判断数据库是否已存在 “推广关键词对应多个搜索关键词”
 	 * @param promotionKeyword 推广关键词
 	 * @return true:存在，false：不存在
 	 */
	@Override
	public Boolean ifExistKeyWordMaping(String promotionKeyword) {
		String hql = " from KeyWordMaping where promotionKeyword = ?";
		List<KeyWordMaping> list = commonDao.findHql(hql,promotionKeyword);
		if(list.isEmpty()) {
			return false;
		}
		else {
			return true;
		}	
	}
}
